﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace TodayWhoModel
{
    public class AdminModel
    {
        private string email;

        public string Email
        {
            get { return email; }
            set { email = value; }
        }
        private string password;

        public string Password
        {
            get { return password; }
            set { password = value; }
        }

        public bool CheckLogin(string email, string password)
        {
            string ssql = "SELECT * FROM [Admins] WHERE email=@email AND password=@password";

            SqlCommand cmd = new SqlCommand(ssql);

            cmd.Parameters.AddWithValue("@email", email);
            cmd.Parameters.AddWithValue("@password", password);

            SqlDataReader reader = DatabaseHelper.ExecuteSelectSql(cmd);
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    this.Email = reader["email"].ToString();
                    this.Password = reader["password"].ToString();
                }
                return true;
            }
            else
            {
                return false;
            }
        }

    }
}
